﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SedCup.Code.Model;

namespace SedCup.Code.View.Components
{
    public partial class Field : UserControl
    {
        public int FieldId { get; private set; }

        private List<Agent> agents;
        /// <summary>
        /// A mezőn lévő dolgozók listája
        /// </summary>
        public List<Agent> Agents
        {
            get { return agents; }
            set { 
                agents = value;

                this.UpdateAgents();
            }
        }


        public Field() : this(0) { }

        public Field(int id)
        {
            InitializeComponent();

            this.FieldId = id;

            this.labelFieldId.Text = this.FieldId.ToString();
            this.BackColor = Settings.GUI_BACKCOLOR_FIELD;
            this.panelId.BackColor = Settings.GUI_BACKCOLOR_FIELD;
            this.panelRight.BackColor = Settings.GUI_BACKCOLOR_FIELD;
            this.panelTop.BackColor = Settings.GUI_BACKCOLOR_FIELD;
            this.labelFieldId.BackColor = Settings.GUI_BACKCOLOR_FIELD;
        }

        /// <summary>
        /// A mezőn lévő dolgozók megjelenítése
        /// </summary>
        private void UpdateAgents()
        {
            this.panelRight.Controls.Clear();

            if (this.Agents == null || this.Agents.Count == 0)
            {
                this.panelRight.Visible = false;
                return;
            }

            this.panelRight.Visible = true;

            PanelWorkersList workers = new PanelWorkersList();

            workers.Agents = this.Agents;
            workers.Dock = DockStyle.Fill;

            this.panelRight.Controls.Add(workers);
        }
    }
}
